/**
 * @copyright 2018 sinping.com 北京芯平科技股份有限公司. All rights reserved.
 * 本内容仅限于北京芯平科技股份有限公司内部传阅，禁止外泄以及用于其他的商业目的.
 */
package com.sinping.qh.config;

import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.TimeUnit;

/**
 *
 *
 * @author guojie
 * @create 2018/1/3
 */
@Configuration
@ConditionalOnProperty(name="wn.session.cache", havingValue="guava")
public class GuavaConfig {

    @Value("${wn.redis.keyTtl}")
    private String ttl;
    @Bean
    public Cache<String, String> getCache() {
        Cache<String, String> cache = CacheBuilder.newBuilder()
                  .expireAfterWrite(new Long(ttl), TimeUnit.SECONDS).build();
        return cache;
    }
}
